In [9]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
In [12]:
df = pd.read_excel('data/sc_grimmbamspecs.xlsx', parse_cols=[0,1,2,4,5,6,8,9,10,12,13,14,16,17])
col_names = dict(zip(df.columns,['speck1time','speck1count','speck1mass','speck2time','speck2count','speck2mass','speck3time','speck3count','speck3mass','grimmtime','grimmmass','grimmcount','bamtime','bampm2.5']))
df.rename(columns=col_names, inplace=True)
df.head()
Out[12]:
In [13]:
speck1 = pd.DataFrame(data=df.speck1mass)
speck1.index = df.speck1time
speck1.dropna(inplace=True)
speck2 = pd.DataFrame(data=df.speck2mass)
speck2.index=df.speck2time
speck2.dropna(inplace=True)
speck3 = pd.DataFrame(data=df.speck3mass)
speck3.index=df.speck3time
speck3.dropna(inplace=True)
grimm = pd.DataFrame(data=df.grimmmass)
grimm.index = df.grimmtime
grimm.dropna(inplace=True)
bam = pd.DataFrame(data=df['bampm2.5'])
bam.index = df.bamtime
bam.dropna(inplace=True)
In [14]:
plt.figure(figsize=(12,12))
ax = plt.subplot(221)
ax.plot(speck1.index, speck1.speck1mass)
ax = plt.subplot(222)
ax.plot(speck2.index, speck2.speck2mass)
ax = plt.subplot(223)
ax.plot(bam.index, bam['bampm2.5'])
ax = plt.subplot(224)
ax.plot(grimm.index, grimm.grimmmass)
Out[14]:
In [15]:
bam['bampm2.5'] = [min(x, 55) for x in bam['bampm2.5']]
In [16]:
plt.figure(figsize=(12,12))
plt.plot(speck1.index, speck1.speck1mass)
plt.plot(speck2.index, speck2.speck2mass)
plt.plot(grimm.index, grimm.grimmmass)
plt.plot(bam.index, bam['bampm2.5'])
Out[16]:
In [17]:
for td in range(-8, 1):
s1 = speck1.copy()
s2 = speck2.copy()
s1.index = speck1.index.shift(td, freq='1h')
s2.index = speck2.index.shift(td, freq='1h')
joined_df = s1.join(s2, how='inner').join(grimm, how='inner').join(bam, how='inner')
print 'Hours offset:', td
print joined_df.corr()
print
In [18]:
for td in range(-8, 1):
s1 = speck1.copy()
s2 = speck2.copy()
s1.index = speck1.index.shift(td, freq='1h')
s2.index = speck2.index.shift(td, freq='1h')
joined_df = s1.join(s2, how='inner').join(grimm, how='inner')
print 'Hours offset:', td
print joined_df.corr()
print
In [ ]: